package com.hyfrogx.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.MultipartConfigElement;
import java.io.File;

/**
 * TODO
 *
 * @author crazypenguin
 * @version 1.0.0
 * @createdate 2019/4/1
 */
@Configuration
public class MultipartConfig {
    /**
     *文件临时上传路径
     */
    @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        String location  = System.getProperty("user.dir") +"/data/tmp";
        File tmpFile   =new File (location);
        if(!tmpFile.exists()){
            tmpFile.mkdirs();
        }
        factory.setLocation(location);
        return factory.createMultipartConfig();
    }
}
